//
//  Map.m
//  Mapping
//
//  Created by Ken Power on 25/08/2011.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "Map.h"


@implementation Map
@synthesize	mapFrame;
@synthesize file;

- (id)init{
    

	
	//coords
	//ne 52.748243, -6.758394
	//sw 52.734992, -6.792362
	
	mapFrame.origin.x=-6.792362;
	mapFrame.origin.y=52.734992;
	mapFrame.size.width=-6.758394-mapFrame.origin.x;
	mapFrame.size.height=52.748243-mapFrame.origin.y;
	
	file=@"map";
	
	return self;
	
}



- (void)dealloc {
    [super dealloc];
}


- (CGPoint)GetPixelCoordsOnMap:(CGRect)viewFrame:(CLLocation*)location{
	
	NSLog(@"GetPixelcoords");
	NSLog(@"Frame ox:%lf, oy%lf, w:%lf, h%lf",viewFrame.origin.x,viewFrame.origin.y,viewFrame.size.width,viewFrame.size.height);
	
	
	CGPoint pixelOnMap;// pixel position on map
	
	double mapWidth=mapFrame.size.width;
	double distFromLeft=location.coordinate.longitude-mapFrame.origin.x;
	double xPos= distFromLeft/mapWidth;// percentage distance from left edge
	
	
	pixelOnMap.x=xPos*viewFrame.size.width;
	
	double mapHeight=mapFrame.size.height;
	double distFromTop=(mapHeight+mapFrame.origin.y)-location.coordinate.latitude;
	double yPos= distFromTop/mapHeight;// percentage distance from top edge
	
	pixelOnMap.y=yPos*viewFrame.size.height;
	
	return pixelOnMap;
	
}


@end
